Learn R Programming

rphast (version 1.6.9)

[.msa: Extract, replace, reorder MSA

Description

Treat multiple sequence alignment as a matrix where each row corresponds to a sequence for one species, and each column is one position aligned across all species.

Usage

# S3 method for msa
[(x, rows, cols, pointer.only)

Arguments

x

An object of type msa

rows

A numeric vector of sequence indices, character vector (containing sequence name), or logical vector (containing sequences to keep). If logical vector it will be recycled as necessary to the same length as nrow.msa(x).

cols

A numeric vector of alignment columns, or a logical vector containing columns to keep. If logical vector it will be recycled as necessary to the same length as ncol.msa(x). Note that these are in coordinates with respect to the entire alignment. x$idx.offset is ignored here.

pointer.only

If TRUE, return an object which is only a pointer to a structure stored in C (useful for large alignments; advanced use only). In certain cases when the original alignment is stored in R, it may be more efficient return an object in R, in which case this argument will be ignored.

Details

The bracket notation can return a subset of the alignment, or re-order rows and columns.

See Also

sub.msa which can subset columns based on genomic coordinates, and extract.feature.msa which can subset based on genomic coordinates denoted in a features object.

Examples

Run this code
# NOT RUN {
m <- msa(seqs=c("ACGTAT", "AGGTAA", "AGGTAG"),
         names=c("human", "mouse", "rat"))
print(m[c("rat", "rat", "human"), ], print.seq=TRUE)
print(m[c(3,3,1),], print.seq=TRUE)
print(m[c(TRUE, FALSE, TRUE),], print.seq=TRUE)
print(m[TRUE,], print.seq=TRUE)
print("[.msa"(m, "mouse",c(1,6,3,5)), print.seq=TRUE)
# }

Run the code above in your browser using DataLab